-
Notifications
You must be signed in to change notification settings - Fork 5.9k
fix: Make dumb-init PID 1 #4846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dumb-init needs to run as PID 1, otherwise it doesn't do anything. exec dumb-init so it takes over PID 1 once the entrypoint script is done.
@code-asher do you mind reviewing this? |
Codecov Report
@@ Coverage Diff @@
## main #4846 +/- ##
=======================================
Coverage 69.17% 69.17%
=======================================
Files 29 29
Lines 1645 1645
Branches 363 363
=======================================
Hits 1138 1138
Misses 430 430
Partials 77 77 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this!
This change also means that signals to the container are passed to dumb-init, rather than swallowed by the entrypoint script.
Another approach would be to change the entrypoint to invoke dumb-init directly, and use it to run the script, as explained in the docs: https://github.com/Yelp/dumb-init#usage
The entrypoint is defined in the Dockerfile here:
code-server/ci/release-image/Dockerfile
Line 48 in 177f0ed
ENTRYPOINT ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "."] |
We could change that line to:
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "."]
and then change the entrypoint script to exec code-server instead of run dumb-init
@jawnsy I'll defer you then on this one since this is out of my expertise! If you think this works, feel free to merge. |
I tested this locally using the following steps - an additional benefit of this approach is that dumb-init is able to receive and propagate signals to code-server properly, so it stops more quickly (normally, the first stop signal that Docker sends, With the existing approach, we see that the entrypoint script is PID 1 and dumb-init would not be receiving signals directly:
After we switch, dumb-init is PID 1 and handles signals correctly:
I'll merge this after the branch updates and test runs complete. Thanks again for your contribution! |
Exec to dumb-init in entrypoint script, so that it can handle signals and reap subprocesses.
dumb-init needs to run as PID 1, otherwise it doesn't do anything.
exec dumb-init so it takes over PID 1 once the entrypoint script is done.